-
as seen on Exceptional Code
- Search for 'Exceptional Code'
A quick one inspired by real life broken code. What’s wrong in this piece of code?
class Planet
{
public Planet()
{
this.Initialize();
}
public Planet(string name) : this()
{
this.Name = name;
}
private string name = "Unspecified";
…
>>> More
-
as seen on Exceptional Code
- Search for 'Exceptional Code'
Got the inspiration for this one in a recent stackoverflow question.
What should the following code output and why?
class Program
{
class Author
{
public string FirstName { get; set; }
public string LastName { get; set; }
public override string ToString()
…
>>> More
-
as seen on Exceptional Code
- Search for 'Exceptional Code'
It’s time for yet another code trivia and it’s business as usual. What will the following program output to the console?
using System;
using System.Drawing;
using System.Threading;
class Program
{
[ThreadStatic]
static Point Mark = new Point(1, 1);
static void Main()
…
>>> More
-
as seen on Exceptional Code
- Search for 'Exceptional Code'
Lets go for another code trivia, it’s business as usual, you just need to find what’s wrong with the following code:
static void Main(string[] args)
{
using (var file = new FileStream("test", FileMode.Create) { WriteTimeout = 1 })
{
file.WriteByte(0);
…
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
I came across this code today and wondering what are some of the ways we can optimize it.
Obviously the model is hard to change as it is legacy, but interested in getting opinions.
Changed some names around and blurred out some core logic to protect.
private static Payment FindPayment(Order order…
>>> More